package com.bwei.like.mynewstop.manager;

import android.support.v4.app.Fragment;

import com.bwei.like.mynewstop.fragment.LocalCityFragment;
import com.bwei.like.mynewstop.fragment.MainFragment;

import java.util.LinkedHashMap;

/**
 * Created by LiKe on 2016/11/15.
 */
public class FragmentFactory {
    private static LinkedHashMap<String, Fragment> linkedHashMap = new LinkedHashMap<>();

    public static Fragment getFragment(String category) {

        Fragment fragment = linkedHashMap.get(category);
        if (fragment != null) {
            return fragment;
        }

        if (category.equals("news_local")) {
            fragment = new LocalCityFragment();
        } else {
            fragment = MainFragment.getFragment(category);
        }

        linkedHashMap.put(category, fragment);
        return fragment;
    }
}
